Beaker = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_BEAKER_ALL);
	},
	init:function(){
		this.body = new Button(this, 10, TAG_BEAKER, "#beaker.png", this.callback,this);

		var powder=new Button(this.body,9,TAG_POWDER,"#powder.png",this.callback,this);
		powder.setPosition(cc.p(this.body.width*0.55, this.body.height*0.1));
		powder.setOpacity(0);
		
		var film=new Button(this.body,9,TAG_LINE,"#film.png",this.callback,this);
		film.setPosition(cc.p(this.body.width*0.5,0));
		film.setOpacity(0);
	},
	showPowder:function(){
		var fadein=cc.fadeIn(1);
		var powder=this.body.getChildByTag(TAG_POWDER);
		powder.runAction(cc.sequence(cc.delayTime(1),fadein));
	},
	showLine:function(a){
		var fadein=cc.fadeIn(1);
		var film=this.body.getChildByTag(TAG_LINE);
		if(a==ACTION_DO1){
			film.runAction(cc.sequence(fadein,cc.moveBy(1,cc.p(0,this.body.height*0.2))));
		}else{
			film.runAction(cc.sequence(fadein,cc.moveBy(1,cc.p(0,this.body.height*0.6))));
		}
		
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		},this);
		var action=gg.flow.flow.action;
		var flask=ll.run.getChildByTag(TAG_FLASK_ALL);
		var flask1=flask.getChildByTag(TAG_FLASK);
		var film=this.body.getChildByTag(TAG_LINE);
		var glass=ll.run.getChildByTag(TAG_GLASS1_ALL);
		switch (p.getTag()) {
		case TAG_BEAKER:
			var ber=cc.bezierBy(1, [cc.p(-15,30),cc.p(-35, 50),cc.p(-210,200)]);
			var rotate=cc.rotateBy(1,-85);
			if(action==ACTION_DO1||action==ACTION_DO2){
				p.runAction(cc.sequence(cc.spawn(ber,cc.callFunc(function() {
					glass.move();
				}, this)),cc.spawn(rotate,cc.sequence(cc.delayTime(0.8),cc.callFunc(function() {
					flask1.setSpriteFrame("flask/flask6.png");
					film.runAction(cc.moveBy(1,cc.p(0,-this.body.height*0.15)));
					flask.show();
				},this))),cc.delayTime(2),cc.spawn(cc.sequence(rotate.reverse(),ber.reverse()),cc.callFunc(function() {
					glass.moveback();
				}, this)),func));
			}else{
				p.runAction(cc.sequence(cc.spawn(ber,cc.callFunc(function() {
					glass.move();
				}, this)),cc.spawn(rotate,cc.sequence(cc.delayTime(0.8),cc.callFunc(function() {
					flask.showLine();
					film.runAction(cc.moveBy(1,cc.p(0,-this.body.height*0.55)));
				},this))),cc.delayTime(2),cc.spawn(cc.sequence(rotate.reverse(),ber.reverse()),cc.callFunc(function() {
					glass.moveback();
				}, this)),func));
			}
			break;
		default:
			break;
		}
	}
});